//
//  UILabel + Extension.swift
//  XKWeibo
//
//  Created by 小k on 15/11/5.
//  Copyright © 2015年 小k. All rights reserved.
//

import UIKit

extension UILabel {
    
    convenience init (
        title:String,
        titleColor:UIColor = UIColor.lightGrayColor(),
        titleFont:CGFloat = 14,
        screenInset: CGFloat = 0) {
        
        // 调用父类, 保证对象创建完成
        self.init()
        
        text = title
        textColor = titleColor          // 字体颜色
        font = UIFont.systemFontOfSize(titleFont)   //大小
            numberOfLines = 0
            
            if screenInset == 0 {
                textAlignment = .Center
            } else {
                // 设置label的最大宽度
                preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
                textAlignment = .Left
            }
    }
    
    
    
}
